home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / formbe1r / frmttt.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-09  |  14.7 KB  |  525 lines

  1. VERSION 5.00
  2. Begin VB.Form frm2Player 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Two Player Tic Tac Toe"
  6.    ClientHeight    =   2625
  7.    ClientLeft      =   150
  8.    ClientTop       =   435
  9.    ClientWidth     =   3915
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Icon            =   "frmTTT.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2625
  17.    ScaleWidth      =   3915
  18.    StartUpPosition =   3  'Windows Default
  19.    Begin VB.PictureBox Winsock1 
  20.       Height          =   480
  21.       Left            =   4080
  22.       ScaleHeight     =   420
  23.       ScaleWidth      =   1140
  24.       TabIndex        =   12
  25.       Top             =   2280
  26.       Width           =   1200
  27.    End
  28.    Begin VB.CommandButton Command2 
  29.       Caption         =   "E&xit"
  30.       Height          =   375
  31.       Left            =   2760
  32.       TabIndex        =   11
  33.       Top             =   720
  34.       Width           =   975
  35.    End
  36.    Begin VB.CommandButton Command1 
  37.       Caption         =   "New Game"
  38.       Height          =   375
  39.       Left            =   2760
  40.       TabIndex        =   10
  41.       Top             =   240
  42.       Width           =   975
  43.    End
  44.    Begin VB.Timer Timer2 
  45.       Interval        =   1
  46.       Left            =   4080
  47.       Top             =   1920
  48.    End
  49.    Begin VB.Timer Timer1 
  50.       Interval        =   1
  51.       Left            =   4080
  52.       Top             =   1560
  53.    End
  54.    Begin VB.Line Line5 
  55.       BorderColor     =   &H0000FFFF&
  56.       BorderWidth     =   4
  57.       Index           =   7
  58.       X1              =   240
  59.       X2              =   2400
  60.       Y1              =   2280
  61.       Y2              =   120
  62.    End
  63.    Begin VB.Line Line5 
  64.       BorderColor     =   &H0000FFFF&
  65.       BorderWidth     =   4
  66.       Index           =   6
  67.       X1              =   360
  68.       X2              =   2400
  69.       Y1              =   240
  70.       Y2              =   2280
  71.    End
  72.    Begin VB.Line Line5 
  73.       BorderColor     =   &H0000FFFF&
  74.       BorderWidth     =   4
  75.       Index           =   5
  76.       X1              =   2040
  77.       X2              =   2040
  78.       Y1              =   120
  79.       Y2              =   2400
  80.    End
  81.    Begin VB.Line Line5 
  82.       BorderColor     =   &H0000FFFF&
  83.       BorderWidth     =   4
  84.       Index           =   4
  85.       X1              =   1320
  86.       X2              =   1320
  87.       Y1              =   120
  88.       Y2              =   2400
  89.    End
  90.    Begin VB.Line Line5 
  91.       BorderColor     =   &H0000FFFF&
  92.       BorderWidth     =   4
  93.       Index           =   3
  94.       X1              =   480
  95.       X2              =   480
  96.       Y1              =   120
  97.       Y2              =   2400
  98.    End
  99.    Begin VB.Line Line5 
  100.       BorderColor     =   &H0000FFFF&
  101.       BorderWidth     =   4
  102.       Index           =   2
  103.       X1              =   240
  104.       X2              =   2520
  105.       Y1              =   2160
  106.       Y2              =   2160
  107.    End
  108.    Begin VB.Line Line5 
  109.       BorderColor     =   &H0000FFFF&
  110.       BorderWidth     =   4
  111.       Index           =   1
  112.       X1              =   240
  113.       X2              =   2520
  114.       Y1              =   1200
  115.       Y2              =   1200
  116.    End
  117.    Begin VB.Line Line5 
  118.       BorderColor     =   &H0000FFFF&
  119.       BorderWidth     =   4
  120.       Index           =   0
  121.       X1              =   240
  122.       X2              =   2520
  123.       Y1              =   360
  124.       Y2              =   360
  125.    End
  126.    Begin VB.Label turn 
  127.       Height          =   375
  128.       Left            =   4080
  129.       TabIndex        =   9
  130.       Top             =   1200
  131.       Visible         =   0   'False
  132.       Width           =   375
  133.    End
  134.    Begin VB.Label s 
  135.       BackColor       =   &H00000000&
  136.       BackStyle       =   0  'Transparent
  137.       BeginProperty Font 
  138.          Name            =   "MS Sans Serif"
  139.          Size            =   24
  140.          Charset         =   0
  141.          Weight          =   400
  142.          Underline       =   0   'False
  143.          Italic          =   0   'False
  144.          Strikethrough   =   0   'False
  145.       EndProperty
  146.       ForeColor       =   &H00C00000&
  147.       Height          =   615
  148.       Index           =   8
  149.       Left            =   1920
  150.       TabIndex        =   8
  151.       Top             =   1800
  152.       Width           =   615
  153.    End
  154.    Begin VB.Label s 
  155.       BackColor       =   &H00000000&
  156.       BackStyle       =   0  'Transparent
  157.       BeginProperty Font 
  158.          Name            =   "MS Sans Serif"
  159.          Size            =   24
  160.          Charset         =   0
  161.          Weight          =   400
  162.          Underline       =   0   'False
  163.          Italic          =   0   'False
  164.          Strikethrough   =   0   'False
  165.       EndProperty
  166.       ForeColor       =   &H00C00000&
  167.       Height          =   615
  168.       Index           =   7
  169.       Left            =   1200
  170.       TabIndex        =   7
  171.       Top             =   1800
  172.       Width           =   615
  173.    End
  174.    Begin VB.Label s 
  175.       BackColor       =   &H00000000&
  176.       BackStyle       =   0  'Transparent
  177.       BeginProperty Font 
  178.          Name            =   "MS Sans Serif"
  179.          Size            =   24
  180.          Charset         =   0
  181.          Weight          =   400
  182.          Underline       =   0   'False
  183.          Italic          =   0   'False
  184.          Strikethrough   =   0   'False
  185.       EndProperty
  186.       ForeColor       =   &H00C00000&
  187.       Height          =   615
  188.       Index           =   6
  189.       Left            =   360
  190.       TabIndex        =   6
  191.       Top             =   1800
  192.       Width           =   615
  193.    End
  194.    Begin VB.Label s 
  195.       BackColor       =   &H00000000&
  196.       BackStyle       =   0  'Transparent
  197.       BeginProperty Font 
  198.          Name            =   "MS Sans Serif"
  199.          Size            =   24
  200.          Charset         =   0
  201.          Weight          =   400
  202.          Underline       =   0   'False
  203.          Italic          =   0   'False
  204.          Strikethrough   =   0   'False
  205.       EndProperty
  206.       ForeColor       =   &H00C00000&
  207.       Height          =   615
  208.       Index           =   5
  209.       Left            =   1920
  210.       TabIndex        =   5
  211.       Top             =   960
  212.       Width           =   615
  213.    End
  214.    Begin VB.Label s 
  215.       BackColor       =   &H00000000&
  216.       BackStyle       =   0  'Transparent
  217.       BeginProperty Font 
  218.          Name            =   "MS Sans Serif"
  219.          Size            =   24
  220.          Charset         =   0
  221.          Weight          =   400
  222.          Underline       =   0   'False
  223.          Italic          =   0   'False
  224.          Strikethrough   =   0   'False
  225.       EndProperty
  226.       ForeColor       =   &H00C00000&
  227.       Height          =   615
  228.       Index           =   4
  229.       Left            =   1200
  230.       TabIndex        =   4
  231.       Top             =   960
  232.       Width           =   615
  233.    End
  234.    Begin VB.Label s 
  235.       BackColor       =   &H00000000&
  236.       BackStyle       =   0  'Transparent
  237.       BeginProperty Font 
  238.          Name            =   "MS Sans Serif"
  239.          Size            =   24
  240.          Charset         =   0
  241.          Weight          =   400
  242.          Underline       =   0   'False
  243.          Italic          =   0   'False
  244.          Strikethrough   =   0   'False
  245.       EndProperty
  246.       ForeColor       =   &H00C00000&
  247.       Height          =   615
  248.       Index           =   3
  249.       Left            =   360
  250.       TabIndex        =   3
  251.       Top             =   960
  252.       Width           =   615
  253.    End
  254.    Begin VB.Label s 
  255.       BackColor       =   &H00000000&
  256.       BackStyle       =   0  'Transparent
  257.       BeginProperty Font 
  258.          Name            =   "MS Sans Serif"
  259.          Size            =   24
  260.          Charset         =   0
  261.          Weight          =   400
  262.          Underline       =   0   'False
  263.          Italic          =   0   'False
  264.          Strikethrough   =   0   'False
  265.       EndProperty
  266.       ForeColor       =   &H00C00000&
  267.       Height          =   615
  268.       Index           =   2
  269.       Left            =   1920
  270.       TabIndex        =   2
  271.       Top             =   120
  272.       Width           =   615
  273.    End
  274.    Begin VB.Label s 
  275.       BackColor       =   &H00000000&
  276.       BackStyle       =   0  'Transparent
  277.       BeginProperty Font 
  278.          Name            =   "MS Sans Serif"
  279.          Size            =   24
  280.          Charset         =   0
  281.          Weight          =   400
  282.          Underline       =   0   'False
  283.          Italic          =   0   'False
  284.          Strikethrough   =   0   'False
  285.       EndProperty
  286.       ForeColor       =   &H00C00000&
  287.       Height          =   615
  288.       Index           =   1
  289.       Left            =   1200
  290.       TabIndex        =   1
  291.       Top             =   120
  292.       Width           =   615
  293.    End
  294.    Begin VB.Label s 
  295.       BackColor       =   &H00000000&
  296.       BackStyle       =   0  'Transparent
  297.       BeginProperty Font 
  298.          Name            =   "MS Sans Serif"
  299.          Size            =   24
  300.          Charset         =   0
  301.          Weight          =   400
  302.          Underline       =   0   'False
  303.          Italic          =   0   'False
  304.          Strikethrough   =   0   'False
  305.       EndProperty
  306.       ForeColor       =   &H00C00000&
  307.       Height          =   615
  308.       Index           =   0
  309.       Left            =   360
  310.       TabIndex        =   0
  311.       Top             =   120
  312.       Width           =   615
  313.    End
  314.    Begin VB.Line Line4 
  315.       BorderColor     =   &H000000FF&
  316.       BorderWidth     =   4
  317.       X1              =   240
  318.       X2              =   2520
  319.       Y1              =   1680
  320.       Y2              =   1680
  321.    End
  322.    Begin VB.Line Line3 
  323.       BorderColor     =   &H000000FF&
  324.       BorderWidth     =   4
  325.       X1              =   240
  326.       X2              =   2520
  327.       Y1              =   840
  328.       Y2              =   840
  329.    End
  330.    Begin VB.Line Line2 
  331.       BorderColor     =   &H000000FF&
  332.       BorderWidth     =   4
  333.       X1              =   1800
  334.       X2              =   1800
  335.       Y1              =   120
  336.       Y2              =   2400
  337.    End
  338.    Begin VB.Line Line1 
  339.       BorderColor     =   &H000000FF&
  340.       BorderWidth     =   4
  341.       X1              =   960
  342.       X2              =   960
  343.       Y1              =   120
  344.       Y2              =   2400
  345.    End
  346. Attribute VB_Name = "frm2Player"
  347. Attribute VB_GlobalNameSpace = False
  348. Attribute VB_Creatable = False
  349. Attribute VB_PredeclaredId = True
  350. Attribute VB_Exposed = False
  351. Dim iwon As Boolean
  352. Dim cwon As Boolean
  353. Dim tie As Boolean
  354. Private Sub cmdConnect_Click()
  355. Unload Me
  356. frmConnection.Show
  357. End Sub
  358. Private Sub Command1_Click()
  359. Call New_Game
  360. End Sub
  361. Private Sub Command2_Click()
  362. Call Quiter
  363. End Sub
  364. Private Sub Form_Load()
  365. turn.Caption = "X"
  366. Line5(0).Visible = False
  367. For c = 1 To 7
  368.     h = h + 1
  369.     Line5(h).Visible = False
  370. Next c
  371. End Sub
  372. Private Sub s_Click(y As Integer)
  373. If turn.Caption = "X" And s(y).Caption = "" And cwon = False And iwon = False And tie = False Then
  374. s(y).Caption = "X"
  375. turn.Caption = "O"
  376. End If
  377. If turn.Caption = "O" And s(y).Caption = "" And cwon = False And iwon = False And tie = False Then
  378. s(y).Caption = "O"
  379. turn.Caption = "X"
  380. End If
  381. End Sub
  382. Private Sub Timer1_Timer()
  383. 'Checks to see if anyone has one
  384. If s(0).Caption = "X" And s(1).Caption = "X" And s(2).Caption = "X" Then
  385. iwon = True
  386. cwon = False
  387. tie = False
  388. Line5(0).Visible = True
  389. End If
  390. If s(3).Caption = "X" And s(4).Caption = "X" And s(5).Caption = "X" Then
  391. iwon = True
  392. cwon = False
  393. tie = False
  394. Line5(1).Visible = True
  395. End If
  396. If s(6).Caption = "X" And s(7).Caption = "X" And s(8).Caption = "X" Then
  397. iwon = True
  398. cwon = False
  399. tie = False
  400. Line5(2).Visible = True
  401. End If
  402. If s(0).Caption = "X" And s(3).Caption = "X" And s(6).Caption = "X" Then
  403. iwon = True
  404. cwon = False
  405. tie = False
  406. Line5(3).Visible = True
  407. End If
  408. If s(1).Caption = "X" And s(4).Caption = "X" And s(7).Caption = "X" Then
  409. iwon = True
  410. cwon = False
  411. tie = False
  412. Line5(4).Visible = True
  413. End If
  414. If s(2).Caption = "X" And s(5).Caption = "X" And s(8).Caption = "X" Then
  415. iwon = True
  416. cwon = False
  417. tie = False
  418. Line5(5).Visible = True
  419. End If
  420. If s(0).Caption = "X" And s(4).Caption = "X" And s(8).Caption = "X" Then
  421. iwon = True
  422. cwon = False
  423. tie = False
  424. Line5(6).Visible = True
  425. End If
  426. If s(2).Caption = "X" And s(4).Caption = "X" And s(6).Caption = "X" Then
  427. iwon = True
  428. cwon = False
  429. tie = False
  430. Line5(7).Visible = True
  431. End If
  432. If s(0).Caption = "O" And s(1).Caption = "O" And s(2).Caption = "O" Then
  433. iwon = False
  434. cwon = True
  435. tie = False
  436. Line5(0).Visible = True
  437. End If
  438. If s(3).Caption = "O" And s(4).Caption = "O" And s(5).Caption = "O" Then
  439. iwon = False
  440. cwon = True
  441. tie = False
  442. Line5(1).Visible = True
  443. End If
  444. If s(6).Caption = "O" And s(7).Caption = "O" And s(8).Caption = "O" Then
  445. iwon = False
  446. cwon = True
  447. tie = False
  448. Line5(2).Visible = True
  449. End If
  450. If s(0).Caption = "O" And s(3).Caption = "O" And s(6).Caption = "O" Then
  451. iwon = False
  452. cwon = True
  453. tie = False
  454. Line5(3).Visible = True
  455. End If
  456. If s(1).Caption = "O" And s(4).Caption = "O" And s(7).Caption = "O" Then
  457. iwon = False
  458. cwon = True
  459. tie = False
  460. Line5(4).Visible = True
  461. End If
  462. If s(2).Caption = "O" And s(5).Caption = "O" And s(8).Caption = "O" Then
  463. iwon = False
  464. cwon = True
  465. tie = False
  466. Line5(5).Visible = True
  467. End If
  468. If s(0).Caption = "O" And s(4).Caption = "O" And s(8).Caption = "O" Then
  469. iwon = False
  470. cwon = True
  471. tie = False
  472. Line5(6).Visible = True
  473. End If
  474. If s(2).Caption = "O" And s(4).Caption = "O" And s(6).Caption = "O" Then
  475. iwon = False
  476. cwon = True
  477. tie = False
  478. Line5(7).Visible = True
  479. End If
  480. If s(0) <> "" And s(1) <> "" And s(2) <> "" And s(3) <> "" And s(4) <> "" And s(5) <> "" And s(6) <> "" And s(7) <> "" And s(8) <> "" And cwon = False And iwon = False Then
  481. tie = True
  482. iwon = False
  483. cwon = False
  484. End If
  485. End Sub
  486. Private Sub Timer2_Timer()
  487. If iwon = True Then
  488. Timer1.Interval = 0
  489. Timer2.Interval = 0
  490. x = MsgBox("X's win.", vbOKOnly, "Tic Tac Toe")
  491. End If
  492. If cwon = True Then
  493. Timer1.Interval = 0
  494. Timer2.Interval = 0
  495. o = MsgBox("O's win.", vbOKOnly, "Tic Tac Toe")
  496. End If
  497. If tie = True Then
  498. Timer1.Interval = 0
  499. Timer2.Interval = 0
  500. ci = MsgBox("There is no winner.  It's a tie.", vbOKOnly, "Tic Tac Toe")
  501. End If
  502. End Sub
  503. Private Sub Quiter()
  504. Unload Me
  505. frmTTTMain.Show
  506. End Sub
  507. Private Sub New_Game()
  508. s(0).Caption = ""
  509. For Index = 1 To 8
  510.     num = num + 1
  511.     s(num).Caption = ""
  512. Next Index
  513. Line5(0).Visible = False
  514. For i = 1 To 7
  515.     x = x + 1
  516.     Line5(x).Visible = False
  517. Next i
  518. Timer1.Interval = 1
  519. Timer2.Interval = 1
  520. cwon = False
  521. iwon = False
  522. tie = False
  523. turn.Caption = "X"
  524. End Sub
  525.